//es5中作用域
var callbacks = [];
for(var i=0;i<=2;i++){
	callbacks[i] = function(){
		return i * 2 
	}
}
console.log(callbacks[0]())
console.log(callbacks[1]())
console.log(callbacks[2]())
//es6中作用域
let callbacks2 = [];
for(let i=0;i<=2;i++){
	callbacks2[i] = function(){
		return i * 2 
	}
}
console.log("==================")
console.log(callbacks2[0]())
console.log(callbacks2[1]())
console.log(callbacks2[2]())
console.log("==================")

// !(function(){
// 	var foo = function(){
// 		return 1
// 	}
// 	console.log("foo === 1",foo() === 1)
// })();

;((function(){
	var foo = function(){
		return 1
	}
	console.log("foo === 1",foo() === 1)
 })()) 

{
	function foo(){
		return 3
	}
	console.log("foo === 3",foo()===3)
	{
		function foo(){
		return 3
	}
	console.log("foo === 4",foo()===4)
	}
	console.log("foo === 3",foo()===3)
}